<div class='header'>
    <!-- line 2 -->
    <div class='header_row'>
        <ul class='header_logo'>
            <a href='/'><img src='{$osslink}static/index/image/index/LOGO-1.png?{$version}'/></a>
        </ul>
        <ul class='header_introduct'>
            <dl class='header_introbtn'>
                <span><b>{:__('我有需求')}：</b></span>
                <a href="/index/Index/release" target="blank" class='layui-btn layui-btn-radius layui-btn-warm'><b>{:__('发布任务')}</b></a>
            </dl>
            <dl class="header_why">
                <span><a href="/howtomakemoney-a31">{:__('写手如何投稿接单赚钱')}</a></span>
            </dl>
        </ul>
    </div>
    <!-- line 3 -->
    <div class='header_row'>
        <ul id='header_tab' class="layui-tab-title header_tab">
            <li date-flag = '1' data-target="/">{:__('首页')}</li>
            <li date-flag = '2' data-target="/index/Index/release">{:__('约稿征文')}</li>
            <li date-flag = '3' data-target="/index/Index/tasklist">{:__('任务大厅')}</li>
            <li date-flag = '4' data-target="/index/Artical/articallist">{:__('写手咨询')}</li>
            <li date-flag = '5' data-target="/question_consultation-a39">{:__('问题咨询')}</li>
            <li date-flag = '6' data-target="/mrgg-a38">{:__('平台公告')}</li>
        </ul>
        <!-- <ul class="header_adv">
            <dl class="header_vip"><i class="layui-icon">&#xe62e;</i><a href="">{:__('VIP写手')}</a></dl>
        </ul> -->
    </div>
    <!-- line 4 -->
    <div class='header_row'>
        <ul class='header_choose'>
            <dl class='header_sel'>
                <!-- <div class="layui-inline"> -->
                    <!-- layui-form-selected -->
                    <div class="layui-unselect layui-form-select">
                        <div class="layui-select-title">
                            <input type="text" placeholder="{:__('任务分类')}" value="{:__('任务分类')}" readonly="true" unselectable="on" class="layui-input layui-unselect">
                            <i class="layui-edge"></i>
                        </div>
                        <dl class="layui-anim layui-anim-upbit task_list_header" id="task_list_header">
                        </dl>
                        <div class='tab_choose' id="tab_choose">
                        </div>
                    </div>
                  <!-- </div> -->
            </dl>
            
        </ul>
        <ul class='layui-nav header_search'>
            <dl class="layui-nav-item">
                <a data-target="title"><span id="header_task_title">{:__('任务标题')}</span></a>
                <dl class="layui-nav-child">
                    <dd><a data-target="title">{:__('任务标题')}</a></dd>
                    <!-- <dd><a href="">任务发布者</a></dd> -->
                    <dd><a data-target="mission_no">{:__('任务号')}</a></dd>
                </dl>
            </dl>
            <dl class="header_input">
                <input class="layui-input" type="text">
            </dl>
            <dl class="header_btn">
                <button id="header_search_btn" class="layui-btn layui-btn-warm">{:__('搜索')}</button>
            </dl>
            <dl class="header_high_search">
                <span><a href="/index/Task/highsearch">{:__('高级搜索')}</a></span>
            </dl>
        </ul>
    </div>
    <script>
        var top_tab = "{$top_tab}";
        top_tab = parseInt(top_tab);
        if(top_tab>0){
            $("#header_tab li[date-flag="+"{$top_tab}"+"]").addClass('tab_hover');
        }
        $(".header_sel .layui-unselect").click(function(){
            var _this = $(this);
            if(_this.hasClass("layui-form-selected")){
                _this.removeClass("layui-form-selected");
            } else {
                _this.addClass("layui-form-selected");
            }
        });
        $("#header_tab li").click(function(){
            var _this = $(this);
            var url = _this.attr("data-target");
            window.location.href=url;
        });
        function getMission()
        {
            var mission_category = getLocalStorage("mission_category");
            var mission_categoryObj = JSON.parse(mission_category);
            var htl = "";
            var j = 0;
            for(i in mission_categoryObj){
                if(j == 8){
                    break;
                }
                htl += "<dd lay-value='"+mission_categoryObj[i]['id']+"'><i class='fa fa-fighter-jet' aria-hidden='true'></i><a href='/index/Index/tasklist?id="+mission_categoryObj[i]['id']+"' class='mission_category_name'>"+mission_categoryObj[i]['name']+"</a></dd>";
                j++;
            }
            htl += "<a href='/index/Index/tasklist'>{:__('全部交易分类')}>></a>";
            $("#task_list_header").html(htl);
        }
        var mission_category = getLocalStorage("mission_category");
        if(mission_category != '' && mission_category != null && mission_category != undefined){
            getMission();
        } else {
            var objs = {'mission_category':1};
            CacheLoad(objs);
            $(document).queue('mission_category,',function(){
                getMission();
                $(document).dequeue('mission_category,');
            });
        }
        $("#tab_choose").css("display",'none');
        $(document).on("mouseover","#task_list_header dd",function(){
            $("#tab_choose").css("display",'flex');
            var _this = $(this);
            var v = _this.attr("lay-value");
            var tops = parseInt(_this[0]['offsetTop'])+44;
            _this.css("background","white");
            $("#tab_choose").css("top",tops);
            var mission_category = getLocalStorage("mission_category");
            var mission_categoryObj = JSON.parse(mission_category);
            var title = _this.text();
            htl = "<h6>"+title+"</h6><div>";
            var nowtab = mission_categoryObj[v]['_child'];
            var j = 1;
            for(i in nowtab){
                if(j%3==0){
                    htl += "<a href='/index/Index/tasklist?id="+nowtab[i]['cat_id']+"'>"+nowtab[i]['name']+"</a></div><div>";
                } else {
                    htl += "<a href='/index/Index/tasklist?id="+nowtab[i]['cat_id']+"'>"+nowtab[i]['name']+"</a>";
                }
                j++;
            }
            $("#tab_choose").html(htl);
        });
        var overflag = 0
        $(document).on("mouseout","#task_list_header dd",function(){
            var _this = $(this);
            _this.css("background","#FCF6ED");
            if(overflag == 0){
                $("#tab_choose").css("display",'none');
            }
        });
        $(document).on("mouseover","#tab_choose",function(){
            overflag = 1;
            $("#tab_choose").css("display",'flex');
        });
        $(document).on("mouseout","#tab_choose",function(){
            $("#tab_choose").css("display",'none');
            overflag = 0;
        });
        $(document).on("click","#tab_choose a",function(){
            if(!$(".layui-form-select").hasClass("layui-form-selected")){
                $(".layui-form-select").addClass("layui-form-selected");
            }
        });
        $(".header_search .layui-nav-item a").mouseenter(function(){
            return false;
        });
        $(".header_search .layui-nav-item a").click(function(){
            if($(".header_search .layui-nav-item .layui-nav-child").hasClass("layui-show")){
                $(".header_search .layui-nav-item .layui-nav-child").removeClass("layui-show");
                $(".header_search .layui-nav-item a i").addClass("layui-icon-down");
                $(".header_search .layui-nav-item a i").removeClass("layui-icon-up");
            } else {
                $(".header_search .layui-nav-item .layui-nav-child").addClass("layui-show");
                $(".header_search .layui-nav-item a i").removeClass("layui-icon-down");
                $(".header_search .layui-nav-item a i").addClass("layui-icon-up");
            }
        });
        $(".header_search .layui-nav-item .layui-nav-child a").click(function(){
            var _this = $(this);
            $("#header_task_title").parent().attr("data-target",_this.attr("data-target"));
            var htl =  _this.html();
            $("#header_task_title").html(htl);
        })
        $("#header_search_btn").click(function(){
            names = $("#header_task_title").parent().attr("data-target");
            var val  = $(".header_input input").val();
            if(val == ''){
                layer.msg("{:__('搜索数据不能为空')}",{icon:2});
                return false;
            }
            var param = "";
            if(val != ''){
                param = "?"+names+"="+val;
            }
            window.location.href="/index/Index/tasklist"+param
        });
    </script>
</div>